//
//  NSString+FormatString.m
//  New_Runway
//
//  Created by 邢毅 on 2018/5/31.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "NSString+FormatString.h"

@implementation NSString (FormatString)

+ (NSString *)getCarLicenceDate:(NSInteger)carLicenceDate carLicenceState:(NSInteger)carLicenceState {
    
    if (carLicenceState == 1) {
        return [NRWCarTurnTime timestampSwitchTime:carLicenceDate andFormatter:@"yyyy-MM"];
    } else if (carLicenceState == 2) {
        return @"未上牌";
    } else if (carLicenceState == 3) {
        return @"新车";
    }
    return @"";
}

+ (NSString *)getCarMileage:(NSNumber *)mileage {
    
    if (mileage.floatValue == 0) {
        return @"未填写";
    } else if (mileage.floatValue > 0 && mileage.floatValue < 0.1) {
        return [NSString stringWithFormat:@"%d公里", (int)(mileage.floatValue * 1000)];
    } else {
        return [NSString stringWithFormat:@"%.2f万公里", mileage.floatValue];
    }
}

+ (NSString *)getCarPrice:(CGFloat)price {
    
    if (price == 0) {
        return @"面议";
    } else {
        return [NSString stringWithFormat:@"%.2f万", price];
    }
}

+ (NSString *)getShareCarDetailUrlWithMarketId:(NSString *)marketId shopId:(NSString *)shopId carId:(NSString *)carId {
    
    return [NSString stringWithFormat:@"%@/mshop/src/cars_share.html?marketId=%@&shopId=%@&imgUrl=%@&customerShopId=false&carId=%@&os=false&shareUserName=%@4&shareUserMobile=%@", Api, marketId, shopId, ImageApi, carId, [NRWCarUser sharedUser].userName, [NRWCarUser sharedUser].userMobile];
}

@end
